package cn.javase.base.io._01_File相关的流;

import org.junit.jupiter.api.Test;

import java.io.FileWriter;
import java.io.IOException;

public class FileWriterTest {

    /* 写出文本 */
    @Test
    public void testFileWriter() {
        try(FileWriter fileWriter = new FileWriter("D:\\Code\\study\\JavaCode\\JavaSEDemo\\base\\src\\main\\java\\cn\\javase\\base\\io\\_01_File相关的流\\文本输出.txt")) {
            fileWriter.write("Hello World！");
            fileWriter.write("I'm a file writer.", 0, 10);
            fileWriter.write("\n人生如戏，喝不喝Java".toCharArray());
            fileWriter.write("\n人生如戏，喝不喝Java".toCharArray(), 0, 5);
            fileWriter.flush();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

}
